package com.ktjiaoyu.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ConcurrentModel;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

@Controller
public class HelloController{
    private static final Logger LOGGER= LoggerFactory.getLogger(HelloController.class);


    @RequestMapping("/hello")
    protected ModelAndView hello(@RequestParam(value = "name") String name,@RequestParam(value = "password") String password, Model model)throws Exception{
//        LOGGER.info("Spring MVC框架搭建成功，当前请求路径：{}",request.getRequestURI());

        ModelAndView mv=new ModelAndView("hello");
        mv.getModel().put("name",name);
        mv.getModel().put("password",password);

        return mv;
    }

    @RequestMapping("/login")
    protected ModelAndView login(HttpServletRequest request)throws Exception{
        LOGGER.info("Spring MVC框架搭建成功，当前请求路径：{}",request.getRequestURI());

        return new ModelAndView("login");
    }
}
